package com.jcfk.eam.controller.bd;

import cn.hutool.core.util.StrUtil;
import com.jcfk.common.business.enums.AvailableStatus;
import com.jcfk.common.business.log.annotation.RequestLogHeader;
import com.jcfk.common.business.utils.DataBindHelper;
import com.jcfk.common.web.domain.DataPage;
import com.jcfk.common.web.domain.ReqPageParam;
import com.jcfk.common.web.domain.RetPage;
import com.jcfk.common.web.domain.RetResult;

import com.jcfk.eam.domain.dto.base.EamTeamMemberAbilityFileDTO;
import com.jcfk.eam.domain.query.base.EamTeamMemberAbilityFileQuery;
import com.jcfk.eam.service.base.EamTeamMemberAbilityFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

import com.jcfk.common.core.utils.ExcelUtils;
/**
 * 班组成员能力附件
 *
 * @author yrl
 * @email 
 * @date 2024-12-20
 */
@Api(tags = {"班组成员能力附件管理"})
@RestController
@RequestMapping("eamteammemberabilityfile")
public class EamTeamMemberAbilityFileController {
    @Autowired
    private EamTeamMemberAbilityFileService eamTeamMemberAbilityFileService;

    /**
     * 分页列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "ReqPageParam<EamTeamMemberAbilityFileQuery>", name = "requestParam", value = "", required = true)
    })
    @ApiOperation("分页查询班组成员能力附件")
    @PostMapping("/queryByPage")
    public RetPage<EamTeamMemberAbilityFileDTO> queryByPage(@RequestBody ReqPageParam<EamTeamMemberAbilityFileQuery> requestParam) {
        DataPage<EamTeamMemberAbilityFileDTO> page = new DataPage<EamTeamMemberAbilityFileDTO>((long) requestParam.getCurrent(),
                (long) requestParam.getSize(),
                requestParam.getSort().getOrderItem(),
            EamTeamMemberAbilityFileDTO.class);
        page = eamTeamMemberAbilityFileService.queryByPage(page, requestParam.getData());

        return new RetPage<>(page);
    }


    /**
     *  班组成员能力附件
     * 根据id 查询详情
     */
    @ApiOperation("查询班组成员能力附件")
    @GetMapping("/get/{id}")
    public RetResult<EamTeamMemberAbilityFileDTO> get(@PathVariable("id") String id) {
            EamTeamMemberAbilityFileDTO item = eamTeamMemberAbilityFileService.get(id);
        return RetResult.ok(item);
    }

    /**
     * 添加/更新管理班组成员能力附件
     */
    @ApiOperation("保存班组成员能力附件")
    @PostMapping("/save")
    @RequestLogHeader(modular = "班组成员能力附件管理", businessType = "保存")
    public RetResult<?> save(@RequestBody @Valid EamTeamMemberAbilityFileDTO eamTeamMemberAbilityFile) {
        // 数据校验
        RetResult ret = eamTeamMemberAbilityFileService.isValid(eamTeamMemberAbilityFile);
        if (!ret.getCode().equals(RetResult.SUCCESS)) {
            return ret;
        }

        if (StrUtil.isEmpty(eamTeamMemberAbilityFile.getId())){
            // 新增
            eamTeamMemberAbilityFileService.insert(eamTeamMemberAbilityFile);
        } else{
            // 更新
            eamTeamMemberAbilityFileService.update(eamTeamMemberAbilityFile);
        }
        return RetResult.ok();

    }

    /**
     *  批量删除班组成员能力附件
     */
    @ApiOperation("批量删除班组成员能力附件")
    @PostMapping("/delete")
    @RequestLogHeader(modular = "班组成员能力附件管理", businessType = "批量删除")
    public RetResult<?> delete(@RequestBody EamTeamMemberAbilityFileDTO eamTeamMemberAbilityFile) {
        return RetResult.ok(eamTeamMemberAbilityFileService.logicDeleteList(eamTeamMemberAbilityFile));
    }





    /**
     *  删除班组成员能力附件
     */
    @ApiOperation("删除班组成员能力附件")
    @PostMapping("/deleteItem/{id}")
    @RequestLogHeader(modular = "班组成员能力附件管理", businessType = "删除")
    public RetResult<?> deleteItem(@PathVariable("id") String id) {
        eamTeamMemberAbilityFileService.deleteItem(id);
        return RetResult.ok();
    }
}
